(async () => {
    const express = require('express');
    const app = express();
    const bodyParser = require('body-parser');

    /** mysql数据库中间接 */ 
    const mysql = require("./middleware/mysql");
    /** 日志 logs.error("内容") */ 
    const logs = require("./middleware/logs");

    /** 路由 */ 
    const routerApi = require("./src/router");
    app.use(bodyParser.json()); // 在请求处理之前，先解析JSON
    app.use(bodyParser.urlencoded({ extended: true }));

    await logs.install(app);
    await mysql.install(app);
    await routerApi.install(app);


    app.get('/', (req, res) => {
        res.send('Hello World!')
    });


    const port = 3000;
    app.listen(3000, () => {
        console.log(`Example app listening on port http://127.0.0.1:${port}/`)
    })


})()